<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增客户信息')" />
</head>
<style>
    label.error {
        position: absolute;
        right: 18px;
        top: 30px;
        color: #ef392b;
        font-size: 12px;
        z-index: 99;
    }
</style>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-customer-add">
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">客户类型：</label>
                    <div class="col-sm-8">
                        <div class="radio-box" th:each="dict : ${@dict.getType('sc_customer_type')}">
                            <input type="radio" th:id="${'status_' + dict.dictCode}" name="customerType" th:value="${dict.dictValue}" th:checked="${dict.default}" required>
                            <label th:for="${'status_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                        </div>
<!--                        <select name="customerType" class="form-control" th:with="type=${@dict.getType('sc_customer_type')}">-->
<!--                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>-->
<!--                        </select>-->
                    </div>
                </div>
            </div>
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">客户名称：</label>
                    <div class="col-sm-8">
                        <input name="customerName" class="form-control" type="text" required maxlength="200">
                    </div>
                </div>
            </div>
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">客户编码：</label>
                    <div class="col-sm-8">
                        <input name="customerCode" class="form-control" type="text" required maxlength="50">
                    </div>
                </div>
            </div>
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">联系人：</label>
                    <div class="col-sm-8">
                        <input name="contactPerson" class="form-control" type="text" required maxlength="20">
                    </div>
                </div>
            </div>
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">联系电话：</label>
                    <div class="col-sm-8">
                        <input name="phone" class="form-control" type="text" required>
                    </div>
                </div>
            </div>
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">电子邮箱：</label>
                    <div class="col-sm-8">
                        <input name="email" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">客户地址：</label>
                    <div class="col-sm-8">
                        <input name="address" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">状态：</label>
                    <div class="col-sm-8">
                        <div class="radio-box" th:each="dict : ${@dict.getType('sys_common_status')}">
                            <input type="radio" th:id="${'status_' + dict.dictCode}" name="status" th:value="${dict.dictValue}" th:checked="${dict.default}" required>
                            <label th:for="${'status_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                        </div>
                    </div>
                </div>
            </div>
<!--            <div class="col-xs-6">-->
<!--                <div class="form-group">-->
<!--                    <label class="col-sm-4 control-label">信用额度：</label>-->
<!--                    <div class="col-sm-8">-->
<!--                        <input name="creditLimit" class="form-control" type="text">-->
<!--                    </div>-->
<!--                </div>-->
<!--            </div>-->
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">备注：</label>
                    <div class="col-sm-8">
                        <textarea name="remark" class="form-control"></textarea>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "scerp/customer"
        $("#form-customer-add").validate({
            focusCleanup: true,
            rules:{
                contactPerson:{
                    required:true,
                    isName:true
                },
                phone: {
                    required: true,
                    isPhone: true
                }
            },
            messages:{
                contactPerson:{
                    required:"请输入中文姓名",
                    isName:"联系人只能为汉字"
                },
                phone:{
                    required:"请输入手机号",
                    isPhone:"请填写正确的11位手机号"
                },
            },
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-customer-add').serialize());
            }
        }
    </script>
</body>
</html>